package com.example.idachuappone.utils;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnCancelListener;
import android.content.DialogInterface.OnDismissListener;
import android.content.DialogInterface.OnShowListener;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.idachuappone.R;

public class CusProSmallBgDialog {
    private Dialog dialog;
    private TextView txt_msg;

    class AnonymousClass_1 implements OnShowListener {
        private final /* synthetic */ Animation val$anim;
        private final /* synthetic */ ImageView val$img_dg;

        AnonymousClass_1(ImageView imageView, Animation animation) {
            this.val$img_dg = imageView;
            this.val$anim = animation;
        }

        public void onShow(DialogInterface dialog) {
            this.val$img_dg.startAnimation(this.val$anim);
        }
    }

    class AnonymousClass_2 implements OnDismissListener {
        private final /* synthetic */ ImageView val$img_dg;

        AnonymousClass_2(ImageView imageView) {
            this.val$img_dg = imageView;
        }

        public void onDismiss(DialogInterface dialog) {
            this.val$img_dg.clearAnimation();
        }
    }

    public CusProSmallBgDialog(Context ctx) {
        View view = LayoutInflater.from(ctx).inflate(R.layout.view_cus_progress_small_black_bg_dialog, null);
        ImageView img_dg = (ImageView) view.findViewById(R.id.img_dg);
        Animation anim = AnimationUtils.loadAnimation(ctx, R.anim.cus_dialog_progress_rotate);
        anim.setInterpolator(new LinearInterpolator());
        this.txt_msg = (TextView) view.findViewById(R.id.txt_msg);
        this.dialog = new Dialog(ctx, 2131361799);
        this.dialog.setContentView(view);
        this.dialog.setCanceledOnTouchOutside(false);
        this.dialog.setOnShowListener(new AnonymousClass_1(img_dg, anim));
        this.dialog.setOnDismissListener(new AnonymousClass_2(img_dg));
    }

    public void show() {
        this.dialog.show();
    }

    public void dismiss() {
        this.dialog.dismiss();
    }

    public void setCancelable(boolean cancel) {
        this.dialog.setCancelable(cancel);
    }

    public void setMsg(String msg) {
        this.txt_msg.setText(msg);
    }

    public void setOnCancelListener(OnCancelListener cancelListener) {
        this.dialog.setOnCancelListener(cancelListener);
    }
}
